<?php
//修改密码功能实现
include 'connect.php';
$username = $_COOKIE['username'];
$oldPassword = $_POST['oldPassword'];
$newPassword = $_POST['newPassword'];

// 查询数据库
$sql = "SELECT * FROM member WHERE username='$username' AND password='$oldPassword'";
$result = mysqli_query($link, $sql);

if ($result && mysqli_num_rows($result) > 0) {
   // 密码正确，执行密码修改操作
   $updateSql = "UPDATE member SET password='$newPassword' WHERE username='$username'";
   $updateResult = mysqli_query($link, $updateSql);

   if ($updateResult) {
       echo "密码修改成功";
   } else {
       echo "密码修改失败：" . mysqli_error($link);
   }
} else {
   echo "密码错误，请重新输入。";
}